#include <iostream>
using namespace std;
class Thing
{
private:
    double v, m, n;

public:
    Thing(double n_ = 0, double v_ = 0, double m_ = 0) : n(n_), v(v_), m(m_) {}
    double GetV() { return v; }
    double GetM() { return m; }
    double GetN() { return n; }
    friend bool operator>(Thing &A, Thing &B)
    {
        if (A.v > B.v)
        {
            return true;
        }
        else if (A.v == B.v)
        {
            if (A.m < B.m)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
};
template <typename T>
long Divide(T arr[], long p, long r)
{
    T x = arr[r - 1];
    long i = p - 1;
    for (int j = p; j < r - 1; j++)
    {
        if (arr[j] > x)
        {
            i++;
            swap(arr[j], arr[i]);
        }
    }
    swap(arr[i + 1], arr[r - 1]);
    return i + 1;
}
template <typename T>
void QuickSort(T arr[], long p, long r)
{
    if (p < r)
    {
        long q = Divide(arr, p, r);
        QuickSort(arr, p, q);
        QuickSort(arr, q + 1, r);
    }
}
int main()
{
    int n = 0;
    cin >> n;
    Thing *T = new Thing[n];
    double v, m;
    for (int i = 0; i < n; i++)
    {
        cin >> v >> m;
        T[i] = Thing(i + 1, v, m);
    }
    QuickSort(T, 0, n);
    for (int i = 0; i < n; i++)
    {
        cout << T[i].GetN() << " ";
    }
    delete[] T;
    return 0;
}